/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.avbravo.p2cnb;

import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
//import org.openide.util.ImageUtilities;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.NotifyDescriptor;
import org.openide.awt.StatusDisplayer;

/**
 * Top component which displays something.
 */
@ConvertAsProperties(dtd = "-//org.avbravo.p2cnb//MigradorP2C//EN",
autostore = false)
public final class MigradorP2CTopComponent extends TopComponent {

    Sesion sesion = new Sesion();
    boolean postgresql = false;
    boolean couchdb = false;
    private static MigradorP2CTopComponent instance;
    /** path to the icon used by the component and its open action */
//    static final String ICON_PATH = "SET/PATH/TO/ICON/HERE";
    private static final String PREFERRED_ID = "MigradorP2CTopComponent";

    public MigradorP2CTopComponent() {
        initComponents();
        setName(NbBundle.getMessage(MigradorP2CTopComponent.class, "CTL_MigradorP2CTopComponent"));
        setToolTipText(NbBundle.getMessage(MigradorP2CTopComponent.class, "HINT_MigradorP2CTopComponent"));
//        setIcon(ImageUtilities.loadImage(ICON_PATH, true));

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jButtonPostgresql = new javax.swing.JButton();
        jTextFieldIpPostgresql = new javax.swing.JTextField();
        jTextFieldPuertoPostgresql = new javax.swing.JTextField();
        jTextFieldDataBasePostgresql = new javax.swing.JTextField();
        jTextFieldUserPostgresql = new javax.swing.JTextField();
        jPasswordFieldPostgresql = new javax.swing.JPasswordField();
        jPanel4 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldIpCouchdb = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldPuertoCouchdb = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTextFieldUserCouchdb = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jPasswordFieldCouchdb = new javax.swing.JPasswordField();
        jButtonCouchdb = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        jTextFieldPrefijo = new javax.swing.JTextField();
        jButtonMigrar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaTablas = new javax.swing.JTextArea();
        jPanel6 = new javax.swing.JPanel();
        jComboBoxFormatoFecha = new javax.swing.JComboBox();

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/p2cnb/postgresql.png"))); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jLabel2.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jLabel3.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jLabel4.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jLabel5.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jLabel6.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(jButtonPostgresql, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jButtonPostgresql.text")); // NOI18N
        jButtonPostgresql.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPostgresqlActionPerformed(evt);
            }
        });

        jTextFieldIpPostgresql.setText(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jTextFieldIpPostgresql.text")); // NOI18N

        jTextFieldPuertoPostgresql.setText(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jTextFieldPuertoPostgresql.text")); // NOI18N

        jTextFieldDataBasePostgresql.setText(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jTextFieldDataBasePostgresql.text")); // NOI18N

        jTextFieldUserPostgresql.setText(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jTextFieldUserPostgresql.text")); // NOI18N

        jPasswordFieldPostgresql.setText(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jPasswordFieldPostgresql.text")); // NOI18N
        jPasswordFieldPostgresql.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPasswordFieldPostgresqlActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonPostgresql)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldIpPostgresql, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldPuertoPostgresql, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldDataBasePostgresql, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jPasswordFieldPostgresql, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextFieldUserPostgresql, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)))))
                .addGap(44, 44, 44))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextFieldIpPostgresql, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldPuertoPostgresql, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFieldDataBasePostgresql, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTextFieldUserPostgresql, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jPasswordFieldPostgresql, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonPostgresql)
                .addContainerGap(41, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N

        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/p2cnb/couchdb.png"))); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jLabel7, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jLabel7.text")); // NOI18N

        jTextFieldIpCouchdb.setText(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jTextFieldIpCouchdb.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(jLabel8, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jLabel8.text")); // NOI18N

        jTextFieldPuertoCouchdb.setText(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jTextFieldPuertoCouchdb.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(jLabel10, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jLabel10.text")); // NOI18N

        jTextFieldUserCouchdb.setText(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jTextFieldUserCouchdb.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(jLabel11, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jLabel11.text")); // NOI18N

        jPasswordFieldCouchdb.setText(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jPasswordFieldCouchdb.text")); // NOI18N
        jPasswordFieldCouchdb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPasswordFieldCouchdbActionPerformed(evt);
            }
        });

        org.openide.awt.Mnemonics.setLocalizedText(jButtonCouchdb, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jButtonCouchdb.text")); // NOI18N
        jButtonCouchdb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCouchdbActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButtonCouchdb)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel8))
                                .addGap(31, 31, 31)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldIpCouchdb, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldPuertoCouchdb, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(44, 44, 44))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addGap(18, 18, 18)
                                .addComponent(jPasswordFieldCouchdb, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addGap(24, 24, 24)
                                .addComponent(jTextFieldUserCouchdb, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)))
                        .addGap(65, 65, 65))))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTextFieldIpCouchdb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTextFieldPuertoCouchdb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jTextFieldUserCouchdb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jPasswordFieldCouchdb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(43, 43, 43)
                .addComponent(jButtonCouchdb)
                .addContainerGap(31, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jPanel4.TabConstraints.tabTitle"), jPanel4); // NOI18N

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jPanel5.border.title"))); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(jLabel9, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jLabel9.text")); // NOI18N

        jTextFieldPrefijo.setText(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jTextFieldPrefijo.text")); // NOI18N
        jTextFieldPrefijo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldPrefijoActionPerformed(evt);
            }
        });

        org.openide.awt.Mnemonics.setLocalizedText(jButtonMigrar, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jButtonMigrar.text")); // NOI18N
        jButtonMigrar.setEnabled(false);
        jButtonMigrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonMigrarActionPerformed(evt);
            }
        });

        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jLabel1.text")); // NOI18N

        jTextAreaTablas.setColumns(20);
        jTextAreaTablas.setRows(5);
        jScrollPane1.setViewportView(jTextAreaTablas);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jPanel2.TabConstraints.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/p2cnb/postgresql.png")), jPanel2); // NOI18N

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 245, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 95, Short.MAX_VALUE)
        );

        jTabbedPane2.addTab(org.openide.util.NbBundle.getMessage(MigradorP2CTopComponent.class, "MigradorP2CTopComponent.jPanel6.TabConstraints.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/p2cnb/couchdb.png")), jPanel6); // NOI18N

        jComboBoxFormatoFecha.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "dd/MM/aaaa", "MM/dd/aaaa", "aaaa/MM/dd", "dd/aaaa/MM", "MM/aaaa/dd", "aaaa/dd/MM" }));

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jButtonMigrar)
                                .addComponent(jTextFieldPrefijo, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE))
                            .addComponent(jComboBoxFormatoFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(42, 42, 42))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jTabbedPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)
                        .addGap(34, 34, 34))))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTextFieldPrefijo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(15, 15, 15)
                        .addComponent(jComboBoxFormatoFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
                .addComponent(jButtonMigrar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(36, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE)
                .addGap(51, 51, 51))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(174, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jPasswordFieldPostgresqlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordFieldPostgresqlActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jPasswordFieldPostgresqlActionPerformed

    private void jPasswordFieldCouchdbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordFieldCouchdbActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jPasswordFieldCouchdbActionPerformed

    private void jTextFieldPrefijoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldPrefijoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldPrefijoActionPerformed

    private void jButtonPostgresqlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPostgresqlActionPerformed
        // TODO add your handling code here:
        try {
            String ip = jTextFieldIpPostgresql.getText();
            if (ip == null || ip.equals("")) {
                 JOptionPane.showMessageDialog(this, "Ingrese el ip", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
              //  NotifyDescriptor nd = new NotifyDescriptor.Message("Ingrese el ip");

                jTextFieldIpPostgresql.requestFocus();
                return;
            }
            String spuerto = jTextFieldPuertoPostgresql.getText();
            if (spuerto == null || spuerto.equals("")) {
                JOptionPane.showMessageDialog(this, "Ingrese el puerto", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                jTextFieldPuertoPostgresql.requestFocus();
                return;
            }
            int puerto = Integer.parseInt(spuerto);

            String database = jTextFieldDataBasePostgresql.getText();
            if (database == null || database.equals("")) {
                JOptionPane.showMessageDialog(this, "Ingrese el nombre de la base de datos", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                jTextFieldDataBasePostgresql.requestFocus();
                return;
            }
            String user = jTextFieldUserPostgresql.getText();
            if (user == null || user.equals("")) {
                JOptionPane.showMessageDialog(this, "Ingrese el usuario", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                jTextFieldUserPostgresql.requestFocus();
                return;
            }
            String password = new String(this.jPasswordFieldPostgresql.getPassword());
            if (password == null || password.equals("")) {
                JOptionPane.showMessageDialog(this, "Ingrese el password del usuario", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            jTextFieldPrefijo.setText(database + "_");
            sesion.setIpPostgresql(ip);
            sesion.setPuertoPostgresql(puerto);
            sesion.setDatabasesPostresql(database);
            sesion.setUserPostgresql(user);
            sesion.setPasswordPostgresql(password);
            postgresql = sesion.ConectarPostgresql();
            if (postgresql == false) {
                JOptionPane.showMessageDialog(this, "No se pudo establecer la conexión verifique los datos");

                return;
            }
            sesion.ObtenerListaTablas();

            StatusDisplayer.getDefault().setStatusText("Conexión exitosa a postgresql");
            for (int i = 0; i < sesion.getListaTablas().size(); i++) {

                jTextAreaTablas.append(sesion.getListaTablas().get(i) + "\n");
            }

            if (couchdb == true) {
                jButtonMigrar.setEnabled(true);
            }

        } catch (Exception ex) {
            StatusDisplayer.getDefault().setStatusText("Error conectando a postgresql " + ex.getMessage().toString());
            JOptionPane.showMessageDialog(this, "Error\nMensaje: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);

        }

    }//GEN-LAST:event_jButtonPostgresqlActionPerformed

    private void jButtonCouchdbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCouchdbActionPerformed
        // TODO add your handling code here:
        try {
            String ip = jTextFieldIpCouchdb.getText();
            if (ip == null || ip.equals("")) {
                JOptionPane.showMessageDialog(this, "Ingrese el ip", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                jTextFieldIpCouchdb.requestFocus();
                return;
            }
            String spuerto = jTextFieldPuertoCouchdb.getText();
            if (spuerto == null || spuerto.equals("")) {
                JOptionPane.showMessageDialog(this, "Ingrese el puerto", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                jTextFieldPuertoCouchdb.requestFocus();
                return;
            }
            int puerto = Integer.parseInt(spuerto);

            String user = jTextFieldUserCouchdb.getText();
            if (user == null) {
                user = "";

            }
            String password = new String(this.jPasswordFieldCouchdb.getPassword());
            if (password == null) {
                password = "";

            }
            sesion.setIpCouchdb(ip);
            sesion.setPuertoCouchdb(puerto);
            sesion.setUserCouchdb(user);
            sesion.setPasswordCouchdb(password);
            couchdb = sesion.ConectarCouchDB();
            if (couchdb == false) {
                JOptionPane.showMessageDialog(this, "No se pudo establecer la conexión verifique los datos");

                return;
            }

            StatusDisplayer.getDefault().setStatusText("Conexión exitosa a couchdb");


            if (postgresql == true) {
                jButtonMigrar.setEnabled(true);
            }

        } catch (Exception ex) {

            JOptionPane.showMessageDialog(this, "Error\nMensaje: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);

        }

    }//GEN-LAST:event_jButtonCouchdbActionPerformed

    private void jButtonMigrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMigrarActionPerformed
        // TODO add your handling code here:
        String prefijo = jTextFieldPrefijo.getText();
        if (prefijo == null) {
            prefijo = "";
        }
        String formatoFecha = String.valueOf(jComboBoxFormatoFecha.getSelectedItem());
        sesion.setFormatoFecha(formatoFecha);
        sesion.setPrefijo(prefijo);
        Thread t = new Thread(new NBRunnable());
        t.start();

    }//GEN-LAST:event_jButtonMigrarActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCouchdb;
    private javax.swing.JButton jButtonMigrar;
    private javax.swing.JButton jButtonPostgresql;
    private javax.swing.JComboBox jComboBoxFormatoFecha;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPasswordField jPasswordFieldCouchdb;
    private javax.swing.JPasswordField jPasswordFieldPostgresql;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTextArea jTextAreaTablas;
    private javax.swing.JTextField jTextFieldDataBasePostgresql;
    private javax.swing.JTextField jTextFieldIpCouchdb;
    private javax.swing.JTextField jTextFieldIpPostgresql;
    private javax.swing.JTextField jTextFieldPrefijo;
    private javax.swing.JTextField jTextFieldPuertoCouchdb;
    private javax.swing.JTextField jTextFieldPuertoPostgresql;
    private javax.swing.JTextField jTextFieldUserCouchdb;
    private javax.swing.JTextField jTextFieldUserPostgresql;
    // End of variables declaration//GEN-END:variables

    /**
     * Gets default instance. Do not use directly: reserved for *.settings files only,
     * i.e. deserialization routines; otherwise you could get a non-deserialized instance.
     * To obtain the singleton instance, use {@link #findInstance}.
     */
    public static synchronized MigradorP2CTopComponent getDefault() {
        if (instance == null) {
            instance = new MigradorP2CTopComponent();
        }
        return instance;
    }

    /**
     * Obtain the MigradorP2CTopComponent instance. Never call {@link #getDefault} directly!
     */
    public static synchronized MigradorP2CTopComponent findInstance() {
        TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
        if (win == null) {
            Logger.getLogger(MigradorP2CTopComponent.class.getName()).warning(
                    "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
            return getDefault();
        }
        if (win instanceof MigradorP2CTopComponent) {
            return (MigradorP2CTopComponent) win;
        }
        Logger.getLogger(MigradorP2CTopComponent.class.getName()).warning(
                "There seem to be multiple components with the '" + PREFERRED_ID
                + "' ID. That is a potential source of errors and unexpected behavior.");
        return getDefault();
    }

    @Override
    public int getPersistenceType() {
        return TopComponent.PERSISTENCE_ALWAYS;
    }

    @Override
    public void componentOpened() {
        // TODO add custom code on component opening
    }

    @Override
    public void componentClosed() {
        // TODO add custom code on component closing
    }

    void writeProperties(java.util.Properties p) {
        // better to version settings since initial version as advocated at
        // http://wiki.apidesign.org/wiki/PropertyFiles
        p.setProperty("version", "1.0");
        // TODO store your settings
    }

    Object readProperties(java.util.Properties p) {
        if (instance == null) {
            instance = this;
        }
        instance.readPropertiesImpl(p);
        return instance;
    }

    private void readPropertiesImpl(java.util.Properties p) {
        String version = p.getProperty("version");
        // TODO read your settings according to their version
    }

    @Override
    protected String preferredID() {
        return PREFERRED_ID;
    }
}
